package Jdk8;

import java.util.Arrays;
import java.util.List;

public class StreamDemo02 {
    public static void main(String[] args) {
        List<Integer> list1 = Arrays.asList(1,2,3,4,5,6);
        int sum = list1.stream().filter(x->x%2==0)
                .mapToInt(x ->x)
                .sum();

        System.out.println(sum);



        sum=list1.stream().filter(x->x%2==0)
                .reduce(0,(x,y)->x+y);

        System.out.println(sum);
    }
}
